﻿// License: https://opensource.org/licenses/MIT
// Create Date : 2018-01-01

using System;
using System.Threading;
using Cat.Extensions;

namespace Cat.Core.XLog
{
    /// <summary>
    /// Log用的字符串格式化类
    /// </summary>
    public sealed class LogStringFormator
    {
        public Lazy<string> DoFormat(object message)
        {
            return new Lazy<string>(() => StringEx.SafeToDisplayString(message), LazyThreadSafetyMode.None);
        }
        public Lazy<string> DoFormat(string format, object arg0)
        {
            return new Lazy<string>(() => StringEx.SafeFormat(format, arg0), LazyThreadSafetyMode.None);
        }
        public Lazy<string> DoFormat(string format, object arg0, object arg1)
        {
            return new Lazy<string>(() => StringEx.SafeFormat(format, arg0, arg1), LazyThreadSafetyMode.None);
        }
        public Lazy<string> DoFormat(string format, object arg0, object arg1, object arg2)
        {
            return new Lazy<string>(() => StringEx.SafeFormat(format, arg0, arg1, arg2), LazyThreadSafetyMode.None);
        }
        public Lazy<string> DoFormat(string format, params object[] args)
        {
            return new Lazy<string>(() => StringEx.SafeFormat(format, args), LazyThreadSafetyMode.None);
        }
    }
}
